package org.hhchat.leetcode.bit;

import java.util.ArrayList;
import java.util.List;

public class code693_easy {

    static class Solution {
        public boolean hasAlternatingBits(int n) {
            List<Integer> bin = new ArrayList<>();
            while(n>0){
                bin.add(n%2);
                n/=2;
            }

            for(int i=0;i<bin.size()-1;i++){
                if(bin.get(i)+bin.get(i+1)!=1){
                    return false;
                }
            }
            return true;
        }
    }
    public static void main(String[] args) {
        System.out.println(new Solution().hasAlternatingBits(4));
    }
}
